import React, { Dispatch } from 'react';
import { AcceptanceManageAPI } from '../common/type';

interface AcceptanceRightTableTypes {
  dataSource: Record<string, any>[];
  loading: boolean;
  getAcceptanceTableData: (request: AcceptanceManageAPI.IGridRequestType) => any;
  mapList: Record<string, any>;
  pagination: Record<string, any>; //分页参数
  otherParams: Record<string, any>; //当前请求参数
  searchList: AcceptanceManageAPI.ISearchList;
  reloadTableData: () => void;
  [key: string]: any;
}

/**
 * Context 默认值类型
 */
type ManageContextTypes = {
  rightTableProps: AcceptanceRightTableTypes;
  curRes: Record<string, any>;
  prefixCls: string;
  reloadLeftTree: (res: any) => void;

  leftSelectKeys: string[];
  leftExpandedKeys: string[];
  leftAutoExpandParent: boolean;
  acceptanceDispatch: Dispatch<any>;
  typeSelectRow: Record<string, any>;
  leftSelectName: string[];
};

/**
 * useContext
 * @rightTableProps 公共表格所需参数
 * @curRes 权限
 * @prefixCls 根节点类名
 * @reloadLeftTree 刷新左侧类型
 * @leftSelectKeys 左侧树选中节点Key
 * @leftExpandedKeys 左侧树展开节点Key
 * @leftAutoExpandParent 左侧树是否自动展开
 * @acceptanceDispatch reduce 派发器
 */
const INIT_ACCEPTANCEMANAGE_CONTEXT: ManageContextTypes = {
  rightTableProps: {
    dataSource: [],
    loading: false,
    getAcceptanceTableData: ({}) => {},
    mapList: [],
    pagination: {},
    otherParams: {},
    searchList: [],
    reloadTableData: () => {},
  },
  curRes: {},
  // prefixCls: 'activiti-manage-',
  prefixCls: 'activiti-condition-',
  reloadLeftTree: (res: any) => {},
  leftSelectKeys: [],
  leftExpandedKeys: [],
  leftAutoExpandParent: false,
  acceptanceDispatch: () => {},
  typeSelectRow: {},
  leftSelectName: [],
};

const AcceptanceManageContext = React.createContext(INIT_ACCEPTANCEMANAGE_CONTEXT);

export { AcceptanceManageContext };
